package com.itao.spel;

import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;

import java.util.Map;

/**
 * 内联map
 * @author sjt
 * @Date 2024/10/9 9:49
 */
public class InlineMaps {

    @SuppressWarnings("rawtypes")
    public static void main(String[] args) {
        ExpressionParser parser = new SpelExpressionParser();
        // evaluates to a Java map containing the two entries
        Map inventorInfo = (Map) parser.parseExpression("{name:'Nikola',dob:'10-July-1856'}").getValue();
        System.out.println(inventorInfo); //{name=Nikola, dob=10-July-1856}
        Map mapOfMaps = (Map) parser.parseExpression("{name:{first:'Nikola',last:'Tesla'},dob:{day:10,month:'July',year:1856}}").getValue();
        System.out.println(mapOfMaps); // {name={first=Nikola, last=Tesla}, dob={day=10, month=July, year=1856}}
    }
}
